import BIRDS from "vanta/src/vanta.birds";
import * as THREE from "three";

export const vantaBgInit = function(el) {
  if (/mobile/i.test(navigator.userAgent)) return null;
  const vantaBg = BIRDS({
    el: el,
    THREE: THREE
  });
  // 修改颜色时 cells 需要全大写字母 可生效
  VANTA.BIRDS({
    el: el,
    mouseControls: true,
    touchControls: true,
    gyroControls: false,
    minHeight: 200.0,
    minWidth: 200.0,
    scale: 1.0,
    scaleMobile: 1.0,
    backgroundColor: 0xffffff,
    colorMode: "variance",
    birdSize: 1.3,
    wingSpan: 25.0,
    speedLimit: 4.0,
    separation: 60.0,
    alignment: 50.0,
    cohesion: 50.0,
    quantity: 4.0
  });
  return vantaBg;
};

export const updateBg = function(that) {
  that.$nextTick(() => {
    let resizeEvent = document.createEvent("Event");
    resizeEvent.initEvent("resize", true, true);
    window.dispatchEvent(resizeEvent);
  });
};
